package com.mm.controller;

import com.mm.config.DelayRabbitConfig;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.*;

/**
 * @author wdx
 * @date 2021/1/22 11:06
 */
@RestController
public class RabbitmqController {

    @Autowired
    RabbitTemplate rabbitTemplate;

    @GetMapping("/send/{message}")
    public void sendMq(@PathVariable String message) {
        rabbitTemplate.convertAndSend(DelayRabbitConfig.ORDER_EXCHANGE, DelayRabbitConfig.ORDER_DELAY, message,
                new CorrelationData(UUID.randomUUID().toString()));
    }

    public static void main(String[] args) {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(5,
                10,
                1000,
                TimeUnit.SECONDS,
                new LinkedBlockingQueue(100), Executors.defaultThreadFactory());

    }


}
